#!/anaconda3/envs/Script/bin python3.8
# -*- coding: utf-8 -*-
# ---
# @Software: PyCharm
# @File: environment.py
# @Author: AllenFu
# @Institution: NCHU, China
# @E-mail: nchufujianjian@126.com
# @Site: 运行时环境
# @Time: 11月 25, 2020
# ---
#
import json
import os

relative_env_path = '.runtime/environment.json'
def init(name:str):
    '''
    初始化运行时环境
    '''
    env_abs_path = os.path.join(os.getcwd(),relative_env_path)
    env_data = {'environment':name}
    with open(env_abs_path, 'w+') as f:
        f.write(json.dumps(env_data))

def read()->str:
    '''
    读取环境变量
    '''
    with open(os.path.join(os.getcwd(), relative_env_path)) as f:
        environment = json.loads(f.read())['environment']
        return environment




